<?php

require_once(realpath(dirname(__FILE__)) . "/nettoyage.php");
require_once(realpath(dirname(__FILE__)) . "/hierarchie.php");
require_once(realpath(dirname(__FILE__)) . "/../classes/Reecriture.class.php");

// rewriting produit
function rewrite_prod($ref, $lang=0){

	if(! $lang) $lang=$_SESSION['navig']->lang;

	$prod = new Produit();
	$prod->charger($ref);
	
	$reecriture = new Reecriture();
	$reecriture->charger_param("produit", "&id_produit=" . $prod->id . "&id_rubrique=" . $prod->rubrique, $lang);
	return $reecriture->url;
}

// rewriting rubrique
function rewrite_rub($id, $lang=0){

	if(! $lang) $lang=$_SESSION['navig']->lang;

	$reecriture = new Reecriture();
	$reecriture->charger_param("rubrique", "&id_rubrique=" . $id, $lang);
	return $reecriture->url;
}

// rewriting contenu
function rewrite_cont($id, $lang=0){

	if(! $lang) $lang=$_SESSION['navig']->lang;

	$contenu = new Contenu();
	$contenu->charger($id);
	
	$reecriture = new Reecriture();
	$reecriture->charger_param("contenu", "&id_contenu=" . $contenu->id . "&id_dossier=" . $contenu->dossier, $lang);
	return $reecriture->url;
}

// rewriting dossier
function rewrite_dos($id, $lang=0){

	if(! $lang) $lang=$_SESSION['navig']->lang;

	$reecriture = new Reecriture();
	$reecriture->charger_param("dossier", "&id_dossier=" . $id, $lang);
	return $reecriture->url;

}

?>